Skip to content

fix: repair failing tests and type errors across monorepo - #106

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2153-1785698469
Open

fix: repair failing tests and type errors across monorepo#106
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier3-2153-1785698469

Conversation

@stooit

@stooit stooit commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and type errors in the monorepo. Final state: bun test → 13 pass / 0 fail, tsc --noEmit → clean (exit 0).

Five root causes across four packages, six source/config files changed. No test files, package.json, or lockfiles were modified, and no dependencies were added.

Fixes

Bug File Fix
document is not defined in all React component tests bunfig.toml The old environment = "happy-dom" key was a no-op for Bun's test runner. Replaced with a preload that registers the happy-dom DOM environment so @testing-library/react's render() has a document. Moved 4→8 passing on its own.
Cannot find module 'bun:test' (TS2307 ×4) tsconfig.json Added "types": ["bun-types"] so bun:test resolves under tsc --noEmit. bun-types was already installed.
@e2e/utils has no exported member useThrottle (TS2305) apps/web/src/lib/api.ts The hook was renamed to useDebounce in packages/utils; updated the import and re-export to match the actual exported symbol.
formatDate zero-pads single-digit day (01/03/2024 vs expected 1/03/2024) packages/utils/src/format/date.ts Switched to en-GB + month: "2-digit" so the day is not zero-padded while keeping day-first ordering and a 4-digit year. Verified across single/double-digit day and month.
Icon-only button has no accessible name packages/ui/.../Button.tsx Icon-only buttons now expose an aria-label (from an explicit prop, or string children as a fallback), plus a dev-only warning when none is available. WCAG 2.2 AA SC 4.1.2 remediation.

packages/ui/.../DataTable.tsx received a behaviour-neutral tidy-up (functional state updater + removal of a misleading BUG: comment); the "stale closure" premise turned out to be a false positive — those tests passed once the DOM environment was registered.

Assumptions & decisions

  • Kept the icon-only aria-label fallback (incl. the generic "button" last resort). Review flagged that a generic fallback can mask an unlabelled control from automated audits, but dropping it would fail Button.test.tsx (which asserts a non-null label even with no children). Per the "do not modify tests / fix only what tests require" constraint, the fallback stays. Backlog item, not a blocker.
  • Left formatDateTime on en-AU. It has no failing test; changing it for locale consistency with formatDate would exceed "fix only what tests require." Review confirmed no correctness regression.
  • docs/ scratch output created during review was intentionally not committed.

Verification

  • bun test → 13 pass / 0 fail (the iconOnly requires aria-label line in output is the intended dev warning from the test that deliberately omits the label, not a failure).
  • npx tsc --noEmit → exit 0.
  • git diff --name-only confirmed no test files, package.json, or lockfiles touched.
  • Independent review pass: approved, no must-fix issues.

…nd icon-only button a11y

- bunfig.toml: register happy-dom via preload so @testing-library render() has document
- tsconfig.json: add bun-types so 'bun:test' resolves under tsc --noEmit
- apps/web/src/lib/api.ts: import/re-export renamed hook useDebounce (was useThrottle)
- packages/utils/src/format/date.ts: en-GB + 2-digit month so single-digit day is not zero-padded (day-first, 4-digit year)
- packages/ui Button: provide aria-label for icon-only buttons (WCAG 2.2 SC 4.1.2)

bun test: 13 pass / 0 fail; tsc --noEmit: clean. No test files, package.json, or lockfiles modified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant